﻿Chenxin.UI.BusinessApplyLoose = Chenxin.extend(Chenxin.UI.FormCommon, {
    actionUrl: "/service/ContractApply/ContractApply.ashx",
    //actionUrl1: "/service/logic/ConfirmMainBusinessApply.ashx",
    id: "divLooseBusiness",
    type: 'numal',
    createComboList: function() {
        //获取初始Combo的值
        var _this = this;
        //区域
        var comboRegion = new Chenxin.UI.ParameterCombo({
            name: 'Region',
            containerId: '#Region',
            key: 'System.Region',
            tbxWidth: 120,
            inModelType: 'txt',
            required: false,
            param: { filter: 'bycity' },
            onSelected: function() {
                if (this.getValue() == this.defVal) {
                    comboBlock.clearItems();
                } else {
                    comboBlock.param.subkey = this.getValue();
                    comboBlock.param.recordid = this.getValueRecord()['id'];
                    comboBlock.reload();
                }
            },
            afterSetValue: function(newVal, oldVal) {
                if (newVal != this.defVal) {
                    comboBlock.param.subkey = this.getValue();
                    comboBlock.param.recordid = this.getValueRecord()['id'];

                    if (_this.currentInfo.Block) comboBlock.reload(_this.currentInfo.Block);

                }
            }
        });
        //装修程度
        var fitment = new Chenxin.UI.ParameterCombo({
            containerId: '#house_Fitment',
            name: 'Fitment',
            key: 'House.Fitment',
            inModelType: 'txt',
            tbxWidth: 120
        });
        //建筑年限
        var completeYear = new Chenxin.UI.BuildingYearCombo({
            containerId: '#house_CompleteYear',
            tbxWidth: 120
        });
        //板块
        var comboBlock = new Chenxin.UI.ParameterCombo({
            containerId: '#Block',
            key: 'System.Block',
            tbxWidth: 120,
            colWidth: 90,
            inModelType: 'txt',
            autoLoad: false,
            required: false
        });
        //合同归属（城市）
        var comboBargainCityId = new Chenxin.UI.StructCombo({
            param: { op: 'getcity' },
            containerId: '#BargainCityId',
            name: 'BargainCityId',
            tbxWidth: 120,
            inModelType: 'all',
            txtModelName: 'BargainCityName',
            onSelected: function() {
                if (this.getValue() == this.defVal) {
                    comboBargainCompanyId.clearItems();
                } else {
                    comboBargainCompanyId.param.fatherid = this.getValue();
                    comboBargainCompanyId.reload();
                }
            },
            afterSetValue: function(newVal, oldVal) {
                if (newVal != this.defVal) {
                    comboBargainCompanyId.param.fatherid = newVal;
                    comboBargainCompanyId.reload(_this.currentInfo.BargainCompanyId);
                }
            }
        });
        //合同归属（公司）
        var comboBargainCompanyId = new Chenxin.UI.StructCombo({
            param: { op: 'getcompany' },
            containerId: '#BargainCompanyId',
            name: 'BargainCompanyId',
            inModelType: 'all',
            txtModelName: 'BargainCompanyName',
            tbxWidth: 120,
            autoLoad: false,
            required: true
        });
        //业务门店（城市）
        var comboBuyerCityId = new Chenxin.UI.StructCombo({
            param: { op: 'getcity' },
            containerId: '#BuyerCityId',
            name: 'BuyerCityId',
            tbxWidth: 120,
            inModelType: 'all',
            txtModelName: 'BuyerCityName',
            onSelected: function() {
                if (this.getValue() == this.defVal) {
                    comboBuyerCompanyId.clearItems();
                } else {
                    comboBuyerCompanyId.param.fatherid = this.getValue();
                    comboBuyerCompanyId.reload();
                }
                comboBuyerDepartId.clearItems();

            },
            afterSetValue: function(newVal, oldVal) {
                if (newVal != this.defVal) {
                    comboBuyerCompanyId.param.fatherid = newVal;
                    comboBuyerCompanyId.reload(_this.currentInfo.BuyerCompanyId);
                }
            }
        });
        //业务门店（公司）
        var comboBuyerCompanyId = new Chenxin.UI.StructCombo({
            param: { op: 'getcompany' },
            containerId: '#BuyerCompanyId',
            name: 'BuyerCompanyId',
            inModelType: 'all',
            txtModelName: 'BuyerCompanyName',
            autoLoad: false,
            tbxWidth: 120,
            onSelected: function() {
                if (this.getValue() == this.defVal) {
                    comboBuyerDepartId.clearItems();
                } else {
                    comboBuyerDepartId.param.fatherid = this.getValue();
                    comboBuyerDepartId.reload();
                }
            },
            afterSetValue: function(newVal, oldVal) {
                if (newVal != this.defVal) {
                    comboBuyerDepartId.param.fatherid = newVal;
                    comboBuyerDepartId.reload(_this.currentInfo.BuyerDepartId);
                }
            }
        });
        //业务门店（部门）
        var comboBuyerDepartId = new Chenxin.UI.StructCombo({
            param: { op: 'getcompanydeparts' },
            containerId: '#BuyerDepartId',
            name: 'BuyerDepartId',
            inModelType: 'all',
            txtModelName: 'BuyerDepartName',
            tbxWidth: 120,
            colWidth: 120,
            autoLoad: false,
            required: true,
            hasPage: true,
            hasSearch: true,
            afterSetValue: function(val, txt) {
                if (val != this.defVal) {
                    comboBuyerUserId.loadUser(val)
                }
            },
            onSelected: function() {
                if (this.getValue() != this.defVal) {
                    comboBuyerUserId.loadUser(this.getValue());
                }
            }
            /*
            onSelected: function() {
            if (this.getValue() != this.defVal) {
            comboBuyerUserId.loadUser(this.getValue(), 500);
            }
            }*/
        });

        //客户来源
        var comboCustomerSource = new Chenxin.UI.Combo({
            containerId: '#CustomerSource',
            tbxWidth: 120,
            required: true,
            items: comboCommon.CustomerSource
        });
        //下家业务员
        var comboBuyerUserId = new Chenxin.UI.RichModelTreeCombo({
            containerId: '#txtBuyerUserName',
            textBoxId: 'txtBuyerUserName',
            inModelType: 'all',
            txtModelName: 'BuyerUserName',
            required: true,
            singleSelect: true,
            name: 'BuyerUserId'

        });
        var comboList = [comboRegion, comboBlock, comboBargainCityId, comboBargainCompanyId, comboBuyerCityId, comboBuyerCompanyId, comboBuyerDepartId, comboBuyerUserId, fitment, completeYear, comboCustomerSource];

        var op = Chenxin.Fn.getQueryString('op');
        if (op == 'confirm' || op == 'confirmedit') {//确认业绩申请
            //签约人
            var comboWorkPersonId = new Chenxin.UI.RichModelTreeCombo({
                containerId: '#ContractUserId',
                textBoxId: 'txtContractUserId',
                inModelType: 'all',
                txtModelName: 'ContractUserName',
                required: true,
                singleSelect: true,
                name: 'ContractUserId'
            });
            //签约地点（部门）
            var comboWorkDepartId = new Chenxin.UI.StructCombo({
                param: { op: 'getsigndeparts' },
                containerId: '#ContractDepartmentId',
                name: 'ContractDepartmentId',
                inModelType: 'all',
                tbxWidth: 120,
                txtModelName: 'ContractDepartmentName',
                required: true,
                afterSetValue: function(val, txt) {
                    if (val != this.defVal) {
                        comboWorkPersonId.loadUser(val)
                    }
                },
                onSelected: function() {
                    if (this.getValue() != this.defVal) {
                        comboWorkPersonId.loadUser(this.getValue());
                    }
                }
            });

            comboList.push(comboWorkPersonId, comboWorkDepartId);
        }

        return comboList;
    },
    formPartId: {
        fp_0: '',
        fp_10: 'div_form_1,div_form_4',
        fp_20: 'div_form_3,grid',
        fp_30: 'div_form_2',
        fp_40: '',
        fp_50: 'all'
    },
    setPartDisable: function() {//封帐状态：0=未封；10=解封资料;20=解封业绩分配;30=佣收情况；40=成交瑕疵；50=全封
        if (this.op != 'confirmedit') {
            return;
        }
		var lockStatus = this.currentInfo.LockStatus;
		var archFlg = this.currentInfo.bArchivement;
		//判断最基本资料是否封盘0001(1);
		if ((lockStatus & 1)&& archFlg) {
			Chenxin.Fn.setFormDisable('div_form_1',this.comboList);
			Chenxin.Fn.setFormDisable('div_form_4',[]);
		}
		//判断佣金资料是否封盘0010(2);
		if ((lockStatus & 2)&& archFlg) Chenxin.Fn.setFormDisable('div_form_2',[]);
		
		//判断点数资料是否封盘0100(4);
		if ((lockStatus & 4)&& archFlg) {
			Chenxin.Fn.setFormDisable('div_form_3',[]);
			this.grid.opstatus=false;
		}
		
		/*
        var fpId = this.formPartId['fp_' + this.currentInfo.LockStatus].split(',');
        var comboList = this.currentInfo.LockStatus == 10 ? this.comboList : [];

        //全部设置为Disable
        if (fpId.length && fpId[0] != '') {//不是未封状态，执行全部Disable
            this.grid.opstatus = false;
            Chenxin.Fn.setFormDisable('divContext', this.comboList);
        }

        if (fpId.length && fpId[0] != 'all') {//不是全封状态下，否则不需要解封	

            for (var i = 0; i < fpId.length; i++) {//对需要解封的内容，逐个解封
                if (fpId[i] == 'grid') {
                    this.grid.opstatus = true;
                }
                Chenxin.Fn.setFormEnable(fpId[i], comboList);
            }
        }*/
    },
    initFormValidator: function() {
        //房源地址
        $("#txtHouseAddress").formValidator({
            validatorgroup: this.id,
            onshow: "请输入房源地址！",
            onfocus: "房源地址为必输项",
            oncorrect: " "
        }).inputValidator({
            min: 1,
            empty: {
                leftempty: false,
                rightempty: false,
                emptyerror: "房源地址不能为空！"
            },
            onerror: "房源地址不能为空！"
        });
        //面积
        $("#txtArea").formValidator({
            validatorgroup: this.id,
            onshow: "请输入面积！",
            onfocus: "面积为必输项",
            oncorrect: " "
        }).inputValidator({
            min: 1,
            empty: {
                leftempty: false,
                rightempty: false,
                emptyerror: "面积不能为空！"
            },
            onerror: "面积不能为空！"
        }).functionValidator({
            fun: function(val, elem) {
                return val.isNum();
            },
            onerror: "面积不能为非数值类型！"
        });
        //合同标的
        $("#txtBargainPrice").formValidator({
            validatorgroup: this.id,
            onshow: "请输入合同标的！",
            onfocus: "合同标的为必输项",
            oncorrect: " "
        }).inputValidator({
            min: 1,
            empty: {
                leftempty: false,
                rightempty: false,
                emptyerror: "合同标的不能为空！"
            },
            onerror: "合同标的不能为空！"
        }).functionValidator({
            fun: function(val, elem) {
                return val.isNum();
            },
            onerror: "非数值格式！"
        });

        //上家姓名
        $("#txtVenderName").formValidator({
            validatorgroup: this.id,
            onshow: "请输入上家姓名！",
            onfocus: "上家姓名为必输项",
            oncorrect: " "
        }).inputValidator({
            min: 1,
            empty: {
                leftempty: false,
                rightempty: false,
                emptyerror: "上家姓名不能为空！"
            },
            onerror: "上家姓名不能为空！"
        });
        //上家身份证
        /* $("#txtVenderNo").formValidator({
        validatorgroup: this.id,
        onshow: "请输入上家身份证号！",
        onfocus: "上家身份证号为必输项",
        oncorrect: " "
        }).inputValidator({
        min: 1,
        empty: {
        leftempty: false,
        rightempty: false,
        emptyerror: "上家身份证号不能为空！"
        },
        onerror: "上家身份证号不能为空！"
        }).functionValidator({
        fun: function(val, elem) {
        return val.isIdCardNo();
        },
        onerror: "身份证格式不正确！"
        }); */


        //上家手机
        $("#txtVenderMobile").formValidator({ validatorgroup: this.id,
            onshow: "请输入上家手机！", onfocus: "请输入上家手机", oncorrect: " "
        }).functionValidator({
            fun: function(val, elem) { return val.isMobile(); }, onerror: "手机格式不正确"
        });


        //下家姓名
        $("#txtBuyerName").formValidator({
            validatorgroup: this.id,
            onshow: "请输入下家姓名！",
            onfocus: "下家姓名为必输项",
            oncorrect: " "
        }).inputValidator({
            min: 1,
            empty: {
                leftempty: false,
                rightempty: false,
                emptyerror: "下家姓名不能为空！"
            },
            onerror: "下家姓名不能为空！"
        });
        //下家身份证
        /* $("#txtBuyerNo").formValidator({
        validatorgroup: this.id,
        onshow: "请输入下家身份证号！",
        onfocus: "下家身份证号为必输项",
        oncorrect: " "
        }).inputValidator({
        min: 1,
        empty: {
        leftempty: false,
        rightempty: false,
        emptyerror: "下家身份证号不能为空！"
        },
        onerror: "下家身份证号不能为空！"
        }).functionValidator({
        fun: function(val, elem) {
        return val.isIdCardNo();
        },
        onerror: "身份证格式不正确！"
        }); */

        //下家手机
        $("#txtBuyerMobile").formValidator({ validatorgroup: this.id,
            onshow: "请输入下家手机！", onfocus: "请输入下家手机", oncorrect: " "
        }).functionValidator({
            fun: function(val, elem) { return val.isMobile(); }, onerror: "手机格式不正确"
        });

        //成交日期
        $("#txtDoneDay").focus(function() {
            WdatePicker({ oncleared: function() { $(this).blur(); }, onpicked: function() { $(this).blur(); } })
        }).formValidator({ validatorgroup: this.id,
            onshow: "请输入成交日期!",
            onfocus: "请输入成交日期!",
            oncorrect: " "
        }).inputValidator({
            empty: { leftempty: false, rightempty: false, emptyerror: "成交日期不能为空!" },
            type: "date",
            onerror: "成交日期不能为空!"
        });

        //上家确认佣收
        $("#txtVRealCommision").formValidator({
            validatorgroup: this.id,
            onshow: "请输入上家确认佣收！",
            onfocus: "上家确认佣收为金额格式",
            oncorrect: " "
        }).functionValidator({
            fun: function(val, elem) {
                return val.isNum();
            },
            onerror: "非金额格式！"
        });
        //上家事前折佣
        $("#txtVCommision").formValidator({
            validatorgroup: this.id,
            onshow: "请输入上家事前折佣！",
            onfocus: "上家事前折佣为金额格式",
            oncorrect: " "
        }).functionValidator({
            fun: function(val, elem) {
                return val.isNum();
            },
            onerror: "非金额格式！"
        });
        //上家咨询费
        $("#txtVConsulting").formValidator({
            validatorgroup: this.id,
            onshow: "请输入上家咨询费！",
            onfocus: "上家咨询费为金额格式",
            oncorrect: " "
        }).functionValidator({
            fun: function(val, elem) {
                return val.isNum();
            },
            onerror: "非金额格式！"
        });
        //下家确认佣收
        $("#txtBRealCommision").formValidator({
            validatorgroup: this.id,
            onshow: "请输入下家确认佣收！",
            onfocus: "下家确认佣收为金额格式",
            oncorrect: " "
        }).functionValidator({
            fun: function(val, elem) {
                return val.isNum();
            },
            onerror: "非金额格式！"
        });
        //下家事前折佣
        $("#txtBCommision").formValidator({
            validatorgroup: this.id,
            onshow: "请输入下家事前折佣！",
            onfocus: "下家事前折佣为金额格式",
            oncorrect: " "
        }).functionValidator({
            fun: function(val, elem) {
                return val.isNum();
            },
            onerror: "非金额格式！"
        });
        //下家咨询费
        $("#txtBConsulting").formValidator({
            validatorgroup: this.id,
            onshow: "请输入下家咨询费！",
            onfocus: "下家咨询费为金额格式",
            oncorrect: " "
        }).functionValidator({
            fun: function(val, elem) {
                return val.isNum();
            },
            onerror: "非金额格式！"
        });
    },
    fitCommunityInfo: function() {
        var _data = {};
        _data.CommunityId = this.currentCommunityInfo.CommunityId;
        _data.Community = this.currentCommunityInfo.CommunityName;
        _data.Block = this.currentCommunityInfo.Block;
        _data.Region = this.currentCommunityInfo.Region;
        _data.HouseAddress = this.currentCommunityInfo.Address;
        this.communityInfo = _data;


        this.fitData(_data, true);

        //Chenxin.Fn.setFormValue(this.id, this.comboList, _data);
    },
    initEvent: function() {
        var _this = this;

        $('.x_colexp').collapse({
            getDom: function() {
                return $('#' + this.id.replace('x_btn_col_', 'div_form_'));
            }
        });

        $('#aSubmit').bind('click', { scope: this }, function(e) {
            e.data.scope.save();
        });

        //小区填充
        $('#txtCommunity').autocomplete({
            deferRequestBy: 5,
            width: 200,
            serviceUrl: this.actionUrl + '?op=loadcommunity',
            onSelect: function(value, data) {
                _this.currentCommunityInfo = data;
                _this.fitCommunityInfo();
            }
        });
        $('#txtCurrentFloor').defText({
            deftxt: '所在楼层'
        });
        $('#txtTotalFloor').defText({
            deftxt: '总楼层'
        });
        $('#x_btn_redirect').click(function() {
            if (confirm('确定' + $(this).find('span').html() + '吗？')) {
                switch (_this.op) {
                    case 'confirmview':
                    case 'confirmedit': //确认编辑
                        window.location.href = '/page/Contract_ApplyInfo/ShowListBargain.aspx';
                        break;
                    default: //默认
                        window.location.href = '/page/Contract_ApplyInfo/ShowListContractApply.aspx';
                        break;
                }
            }
            return false;
        });
    },

    initPageInfo: function() {

        var opbtn = $('#x_btn_redirect');
        var title = '';
        var redirect = '';

        switch (this.op) {
            case 'confirm':
                title = '零散业务成交编号申请确认';
                redirect = '返回成交记录管理';
                break;
            case 'confirmedit':
                title = '零散业务成交记录修改';
                redirect = '返回成交记录管理';
                break;
            case 'edit':
                title = '零散业务成交编号申请修改';
                redirect = '返回业绩申请管理';
                break;
            case 'view':
                title = '零散业务成交编号申请查看';
                redirect = '返回业绩申请管理';
                break;
            case 'add':
                title = '零散业务成交编号申请';
                redirect = '返回业绩申请管理';
                break;
            case 'confirmedit':
                title = '零散业务成交记录修改';
                redirect = '返回成交记录管理';
                break;
            case 'confirmview':
                title = '零散业务成交记录查看';
                redirect = '返回成交记录管理';
                break;
        }

        $('#x_span_title').html(title);
        opbtn.find('span').html(redirect);
        document.title = title;
    },
    initData: function() {
        var recordId = Chenxin.Fn.getQueryString('RecordId');

        this.op = Chenxin.Fn.getQueryString('op') || 'add';

        if (this.op == 'confirm' || this.op == 'confirmedit') {
            $('.x-notconfirm-item').remove();
            $('#div_form_confirm').show();
        } else {
            $('#div_form_confirm').remove();
        }

        if (this.op == 'view' || this.op == 'confirmview') {
            this.grid.opstatus = false;
            this.setDisable();


            $('#x_btn_submit').remove();
        }

        this.initPageInfo();

        Chenxin.Fn.getModel(recordId || '', this.actionUrl, function(data) {
            var model = {};
            this.userInfo = data.userInfo;

            if (this.op != 'add') {
                this.applyInfo = data.applyInfo;
                Chenxin.apply(model, this.applyInfo);
            }
            else {
                model.BargainCityId = this.userInfo.CityId;
                model.BargainCompanyId = this.userInfo.CompanyId;
                model.BuyerCityId = this.userInfo.CityId;
                model.BuyerCompanyId = this.userInfo.CompanyId;
                model.BuyerDepartId = this.userInfo.DepartId;
            }

            if (this.op == 'confirmedit' || this.op == 'confirmview') {
                $('#DoneDay').val(model.ContractDate.substr(0, 10));
            }

            if (this.op == 'add') {//添加
                this.initGridData();
            } else {	//编辑，确认的时候
                this.initGridData(data.pointList);
            }

            this.currentInfo = model;
            this.fitData(model);


            this.setPartDisable();

        }, this, (this.op == 'confirmedit' || this.op == 'confirmview') ? 'getconfirminitdata' : 'getlooseinitdata');

    },

    initGridData: function(store) {
        if (!store) {
            Chenxin.Fn.getModel(this.userInfo.DepartId, this.actionUrl, function(data) {
                var record = 'abc_' + Math.random() * 10000000000;
                record = record.replace('.', '');
                var row = {
                    Point: 2,
                    RecordId: record,
                    BuyerOrVenderInfo: '10',
                    EmployeeId: this.userInfo.UserId,
                    Employee: this.userInfo.UserName,
                    DepartId: this.userInfo.DepartId,
                    Depart: this.userInfo.DepartName
                };
                Chenxin.apply(row, data);
                this.grid.render({
                    rows: [row],
                    count: 1
                });
            }, this, 'getparents');
        } else {
            this.grid.render(store);
        }
    },
    createGrid: function() {
        if (!this.grid) {
            var _this = this;
            this.grid = new Chenxin.UI.PointGrid({
                actionUrl: this.actionUrl,
                getFormInitData: function(data) {//获取表单初始化数据
                    var _user = this.findByName('BuyerUserId');
                    var _depart = this.findByName('BuyerDepartId');

                    if (_depart.getValue() != this.defVal) {
                        data.DepartId = _depart.getValue();
                        data.Depart = _depart.getText();
                    } else {
                        data.DepartId = '';
                        data.Depart = '';
                    }
                    if (_user.getValue() != this.defVal) {
                        data.EmployeeId = _user.getValue();
                        data.Employee = _user.getText();
                    } else {
                        data.EmployeeId = '';
                        data.Employee = '';
                    }
                },
                scope: this
            });

        }
    },
    saveSucc: function() {
        //提交成功后转到查询页面
        this.op = Chenxin.Fn.getQueryString('op') || 'add';
        var url = '';
        if (this.op != 'confirmedit')
            url = 'ShowListContractApply.aspx';
        else
            url = 'ShowListBargain.aspx';
        window.location.href = "/page/Contract_ApplyInfo/" + url;
    },
    afterGetFormJson: function(json) {
        this.additionalParam = {};

        if (this.op == 'confirm') {//确认业绩申请

            json.ContractDate = $('#DoneDay').val();
            json.ApplyId = json.RecordId;

            delete json.RecordId;
        }
        if (this.op == 'view') {
            this.setDisable();
        }

        json.BusinessType = 30;
        json.BargainType = 10;

        if (this.op != 'add') {
            json.HouseCode = this.applyInfo.HouseCode;
            json.BusinessType = this.applyInfo.BusinessType;
        }

        if (json.VRealCommision == undefined) json.VRealCommision = "0";
        if (json.BRealCommision == undefined) json.BRealCommision = "0";
        if (json.VCommision == undefined) json.VCommision = "0";
        if (json.BCommision == undefined) json.BCommision = "0";
        if (json.VConsulting == undefined) json.VConsulting = "0";
        if (json.BConsulting == undefined) json.BConsulting = "0";

        if (this.op == 'confirmedit') {
            Chenxin.applyIf(json, this.currentInfo);
        }
        delete json.VStandardCommision;
        delete json.BStandardCommision;

        if (this.grid.store.rows.length) {
            var rows = [];
            for (var i = 0; i < this.grid.store.rows.length; i++) {
                var row = {};
                Chenxin.apply(row, this.grid.store.rows[i]);
                if (row.MajordomoId == null) delete row.MajordomoId;
                if (row.RegionManagerId == null) delete row.RegionManagerId;
                if (row.MangerId == null) delete row.MangerId;
                if (row.DeparterManagerId == null) delete row.DeparterManagerId;
                if (row.EmployeeId == null) delete row.EmployeeId;
                if (row.DepartId == null) delete row.DepartId;
                delete row.RecordId;
                rows.push(row);
            }
            this.additionalParam.PointInfo = '[' + rows.toString() + ']';
        }
    },
    customerFormVal: function(json) {
        var total = this.grid.getTotalPoint();
        if (total != 10) {
            alert('点数10点还没有完全分配，现只分配了其中的' + total + '点');
            return false;
        }
        if (this.grid.store.rows[0]) {
            if (!this.grid.store.rows[0].DeparterManagerId) {
                alert('所有点数分配记录，必须选择店长！');
                return false;
            }
        }

        if (!json.VRealCommision && !json.BRealCommision) {
            alert('上家佣收和下家佣收必须填写一项！')
            return false;
        }


        if ((!json.VRealCommision && json.VConsulting) || parseFloat(json.VRealCommision) < parseFloat(json.VConsulting)) {
            alert('上家咨询费不能大于上家确认佣收！')
            return false;
        }
        if ((!json.BRealCommision && json.BConsulting) || parseFloat(json.BRealCommision) < parseFloat(json.BConsulting)) {
            alert('下家咨询费不能大于下家确认佣收！')
            return false;
        }

        if (this.op == 'confirm' && !$('#DoneDay').val()) {//确认业绩的时候，成绩时间需要输入
            alert('请输入成交时间！');
            return false;
        }

        return true;
    },
    initComponent: function() {
        Chenxin.UI.BusinessApplyLoose.superclass.initComponent.call(this);

        this.createGrid();
        this.initData();
    }

});


dataKeyList='System.Region,House.Fitment';//设置需要获取数据字段数据的KEY,用,分割
getcity=true;//设置需要获取城市下拉框数据

$(document).ready(function(){
	var dom=new Chenxin.UI.BusinessApplyLoose();
});